package testjava.grammar;

public class TestGC {
	public static void main(String[] args) {
		while (Class1.flag) {
			new Class1();
		}
		System.out.println("finalize run times1=" + Class1.i);
		System.runFinalization();
		System.out.println("finalize run times2=" + Class1.i);
		System.gc();
		System.out.println("finalize run times3=" + Class1.i);
	};

}

class Class1 {
	static int i;
	static boolean flag = true;

	Class1() {
		for (int k = 0; k < 2000; k++) {
		}
	}

	public void finalize() {
		i++;
		flag = false;
	}
}
